#include<bits/stdc++.h>
using namespace std;
long long t,n,c=0,cmax=INT_MIN;
struct num{
    long long data,color;
}a[100010];
void solve(int step){
    if(step+1==n){
            c=0;
        for(int i=1;i<=n;i++){
            for(int j=i-1;j>=1;j--){
                if(a[i].color==a[j].color){
                        if(a[i].data==a[j].data){
                            c+=a[j].data;
                        }
                      break;
                }
            }
        }
        cmax=max(c,cmax);
        return ;
    }
    for(int i=1;i<=2;i++){
        a[step].color=i;
        solve(step+1);
    }
}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>t;
    while(t--){
        cin>>n;
        for(int i=1;i<=n;i++)cin>>a[i].data;
        cmax=INT_MIN;
        solve(1);
        cout<<cmax<<" ";
        while(true);
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
